home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Demos / Bowers Development / AppMaker 2.0b5 / Examples / PowerPlant / Gadgets / CProgressBars.cp < prev    next >
Encoding:
Text File  |  1996-03-19  |  3.3 KB  |  178 lines  |  [TEXT/CWIE]

  1. // CProgressBars.cp -- window methods
  2. // Created 3/19/96 12:49 PM by AppMaker
  3.  
  4. #include "CProgressBars.h"
  5.  
  6. #include <UReanimator.h>
  7. #include <URegistrar.h>
  8. #include <LStream.h>
  9. #include <LStdControl.h>
  10. #include "CGadgetsData.h"
  11. #include "CmdCodes.h"
  12.  
  13. #define PPob_ProgressBarsID    203
  14. #define RidL_ProgressBarsID    203
  15.  
  16. Boolean        CProgressBars::sIsRegistered = false;
  17.  
  18. //----------
  19. void
  20. CProgressBars::RegisterClass ()
  21. {
  22.     URegistrar::RegisterClass ('Pros', (ClassCreatorFunc)CProgressBars::CreateProgressBarsStream);
  23.  
  24.     // register the pane classes we use
  25.  
  26.     sIsRegistered = true;
  27. }
  28.  
  29. //----------
  30. CProgressBars*
  31. CProgressBars::CreateProgressBars(
  32.     LCommander            *inSuperCommander,
  33.     CGadgetsData        *inData)
  34. {
  35.     if (!sIsRegistered) {
  36.         RegisterClass ();
  37.     }
  38.  
  39.     CProgressBars        *window;
  40.  
  41.     window = (CProgressBars *)LWindow::CreateWindow(PPob_ProgressBarsID, inSuperCommander);
  42.     window->ConnectToData (inData);
  43.  
  44.     return window;
  45. }
  46.  
  47. //----------
  48. //    This is the function you register with URegistrar to create a
  49. //    CProgressBars from a resource
  50.  
  51. CProgressBars*
  52. CProgressBars::CreateProgressBarsStream(
  53.     LStream    *inStream)
  54. {
  55.     return (new CProgressBars(inStream));
  56. }
  57.  
  58. //----------
  59. CProgressBars::CProgressBars()
  60. {
  61. }
  62.  
  63. //----------
  64. CProgressBars::CProgressBars(
  65.     LStream    *inStream)
  66.         : LWindow(inStream)
  67. {
  68. }
  69.  
  70. //----------
  71. CProgressBars::~CProgressBars()
  72. {
  73. }
  74.  
  75. //----------
  76. //    This member function gets called once the containment hierarchy that contains
  77. //    this pane has been built. It gives us a chance to get data members for
  78. //    interesting subviews, and to do other operations now that our subviews exist.
  79. void
  80. CProgressBars::FinishCreateSelf()
  81. {
  82.     mRectBar = (LStdControl *)FindPaneByID ('Rect');
  83.     mBarberBar = (LStdControl *)FindPaneByID ('Barr');
  84.     mProgressBar = (LStdControl *)FindPaneByID ('Pros');
  85.  
  86.     UReanimator::LinkListenerToControls(this, this, RidL_ProgressBarsID);
  87.         // the purpose is to "connect" self to whatever controls
  88.         // that we want to "listen" to
  89.  
  90. // any additional initialization for your window:
  91.  
  92. }
  93.  
  94. //----------
  95. void
  96. CProgressBars::ConnectToData    (CGadgetsData        *inData)
  97. {
  98.     mData = inData;
  99.     inData->AddListener (this);
  100. }
  101.  
  102. //----------
  103. void
  104. CProgressBars::ListenToMessage(
  105.     MessageT    inMessage,
  106.     void        *ioParam)
  107. {
  108.     switch (inMessage) {
  109.  
  110.     default:
  111.         break;
  112.     }
  113. }
  114.  
  115. //----------
  116. Boolean
  117. CProgressBars::ObeyCommand(
  118.     CommandT    inCommand,
  119.     void        *ioParam)
  120. {
  121.     Boolean        cmdHandled = true;
  122.  
  123.     switch (inCommand) {
  124.  
  125.     // +++ Add cases here for the commands you handle
  126.     //        Remember to add same cases to FindCommandStatus below
  127.     //        to enable/disable the commands
  128.  
  129.     default:
  130.             cmdHandled = LWindow::ObeyCommand(inCommand, ioParam);
  131.         break;
  132.     }
  133.  
  134.     return cmdHandled;
  135. }
  136.  
  137. //----------
  138. void
  139. CProgressBars::FindCommandStatus(
  140.     CommandT    inCommand,
  141.     Boolean        &outEnabled,
  142.     Boolean        &outUsesMark,
  143.     Char16        &outMark,
  144.     Str255        outName)
  145. {
  146.     outUsesMark = false;
  147.  
  148.     switch (inCommand) {
  149.  
  150.     // +++ Add cases here for the commands you handle
  151.  
  152.     default:
  153.             LWindow::FindCommandStatus(inCommand, outEnabled,
  154.                                         outUsesMark, outMark, outName);
  155.         break;
  156.     }
  157. }
  158.  
  159. //----------
  160. Boolean
  161. CProgressBars::FocusDraw()
  162. {
  163.     Boolean        focused = LView::FocusDraw();
  164.  
  165.     if (focused) {
  166.         AuxWinHandle    awHndl;
  167.         CTabHandle        awCTable;
  168.         ColorSpec        contentSpec;
  169.  
  170.         GetAuxWin(GetMacPort(), &awHndl);
  171.         awCTable = (**awHndl).awCTable;
  172.         contentSpec = (**awCTable).ctTable [wContentColor];        // should search vs. index
  173.         ::RGBBackColor(&contentSpec.rgb);
  174.     }
  175.  
  176.     return focused;
  177. }
  178.